#pragma once

class BrowsingUI : public Singleton<BrowsingUI>
{
	WMOModel* m_pModel;
	IDirect3DTexture9* m_pPreview;
	Texture* m_pTopLeft, *m_pTopRight, *m_pBotRight, *m_pBotLeft;
	Vertex3FRHWT m_topL[4], m_topR[4], m_botL[4], m_botR[4];
	Vertex2F m_position, m_relClick;
	float m_rotationY;
	float m_distX;
	bool m_titleClicked;
	void ReloadVertices();
	TreeView* m_pModelTree;
	void LoadModels();
	void ParsePath(TreeViewItem* pItem, std::string szBase);
	void ScrollBarProc(VScrollbar<BrowsingUI>* pBar, ui32);
	VScrollbar<BrowsingUI>* m_pTreeScroll;
	ui32 m_numLastItems;
public:
	BrowsingUI();
	void Render3D();
	void Render2D();
	bool OnMouseClick(Vertex2F pos, bool up);
	void OnMouseMove(Vertex2F pos);
	void Expanded(ui32 index);
	void OnItemSelected(std::string wmoName);
};

#define sBrowsing (*BrowsingUI::GetInstance())